<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <a class="add-btn btn btn-sm btn-success"><i class="fa fa-plus" aria-hidden="true"></i> 新增</a>
            </div>
            <!-- START 数据表格 -->
            <table id="relatedTable"
                   data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-side-pagination="server"
                   data-page-size="15"
                   data-url="/sea/finance/rate/findByCnd.do"
                   class="table table-striped table-hover">
            </table>
            <!-- END 数据表格 -->

            <!-- END 右侧数据 -->
        </div>
    </div>
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer,layui,upload'}){}%>
<script>


    var $relatedTable = $('#relatedTable'),selections=[];
    $(function(){
        //指定允许上传的文件类型
        //START 表格配置
        $relatedTable.bootstrapTable({
            columns: [
                {
                    title: '原币',
                    field: 'rateFromName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '兑换币种',
                    field: 'rateToName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '国家',
                    field: 'rateCountry',
                    align: 'center',
                    valign: 'middle',
                    formatter: function(v,r){
                        var result = '';
                        switch (v) {
                            <%
                                for (var dict in dictFun("base_country", "")) {%>
                                case '${dict.detailCode}':
                                    result = '${dict.detailName}';
                                    break;
                                <%
                                }
                            %>
                            default:
                                result = '';
                                break;
                        }
                        return result;
                    }
                },
                {
                    title: '货币名称',
                    field: 'rateName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '最新汇率',
                    field: 'ratePercent',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '更新时间',
                    field: 'modifyTime',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    field: 'operate',
                    title: '操作',
                    width:200,
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){
                $('.edit-btn').on('click',function(){//新增
                    var id=$(this).attr('data-val');
                    layer.open({
                        title: false,
                        closeBtn: 0,
                        type: 2,
                        area: ['100%','100%'],
                        skin: 'layer-ext-espresso',
                        content: ['/sea/finance/rate/editPage.do?id='+id, 'yes']
                    });
                });
                $('.detail-btn').on('click',function(){
                    var id = $(this).attr('data-val');
                    layer.open({
                        type: 2,
                        area: ['700px','500px'],
                        content: ['/sea/finance/rate/record/main.do?rateId='+id, 'yes']
                    });
                });
            }
        });
    });
    //操作菜单
    function optFormatter(value,row){
        var content = '<button class="edit-btn btn btn-xs btn-info" data-val="'+row.id+'" title="修改"><i class="fa fa-edit"></i>  修改</button>';
        content += '&nbsp;<button class="detail-btn btn btn-xs btn-default" data-val="'+row.id+'" title="查看记录"> 查看记录</button>';
        return content;
    }

    $('.add-btn').on('click',function(){//新增
        layer.open({
            title: false,
            closeBtn: 0,
            type: 2,
            area: ['100%','100%'],
            skin: 'layer-ext-espresso',
            content: ['/sea/finance/rate/addPage.do', 'yes']
        });
    });

</script>
</body>
</html>
